﻿using UnityEngine;
using System.Collections;

public class TestBusService : MonoBehaviour 
{
	[SerializeField]
	public BusInformationRequester r;

	public static bool loaded = false;

	void Start()
	{
		r.DoRequest();
	}

	void OnGUI()
	{
		/*
		if(GUI.Button(new Rect(20, 20, 150, 40), "Debug Bus Service"))
		{
			r.DoRequest();
			//StartCoroutine(ExecuteService());
		}
*/
	}

	private IEnumerator ExecuteService()
	{
		HTTP.Request r = new HTTP.Request("GET", Global.URL_BUS_SERVICE);
		
		while(!r.isDone)
		{
			yield return new WaitForEndOfFrame();
		}
		//WWW www = new WWW(Global.URL_BUS_SERVICE);
		//yield return www;
		Debug.Log(r.response.Text);
		SimpleJSON.JSONNode mainNode = SimpleJSON.JSONNode.Parse(r.response.Text);
		Debug.Log(mainNode.Count);


		//Debug.Log(www.text);
		//www.Dispose();
	}
}
